//
//  GifHeader.swift
//  FlameB
//
//  Created by 连俊 on 2020/8/4.
//  Copyright © 2020 连俊. All rights reserved.
//

import UIKit

class GifHeader: MJRefreshGifHeader {
    private var idleImages: [UIImage] = [UIImage]();
    private var refreshingImages: [UIImage] = [UIImage]();
    override func prepare() {
          super.prepare()
          // 设置普通状态的动画图片
          for i in 0...47{
              if let im = UIImage(named: "tutu-\(i)"){
                  refreshingImages.append(im)
              }
          }
          
          for i in 0...23{
              if let im = UIImage(named: "preanimation-\(i)"){
                  idleImages.append(im)
              }
          }
          self.setImages(idleImages, for: MJRefreshState.idle)
          
          self.setImages(refreshingImages, duration:1.5,for: MJRefreshState.refreshing)
          self.setImages(refreshingImages, duration:1.5,for: MJRefreshState.pulling)
          mj_h = 60
      }
  
    override func placeSubviews() {
        super.placeSubviews()
        gifView?.contentMode = .scaleAspectFit
        gifView?.frame = CGRect(x: 0, y: 5, width: mj_w, height: 50)
        stateLabel?.isHidden = true;
    }
}
